//import java.awt.*;
import java.awt.event.*;
import java.io.File;

import javax.swing.*;

public class LogTrackerGUI extends JFrame implements ActionListener {

	 JFileChooser fc;
	 JMenuItem openFile;
	// JMenuBar menuBar;
	// JMenu fileMenu;
	
	public LogTrackerGUI(){
		super("LogTracker 1.0");
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setSize(300,300);
		
		//create menu
		openFile = new JMenuItem("Import File");
		JMenuBar menuBar = new JMenuBar();
		JMenu fileMenu = new JMenu("File");
		
		openFile.addActionListener(this);
		  //Create a file chooser
        fc = new JFileChooser();
		
		fileMenu.add(openFile);
		menuBar.add(fileMenu);
		
		setJMenuBar(menuBar);
		
		//pack();
		setVisible(true);	
	}	
	
	public void actionPerformed(ActionEvent event){
		 if (event.getSource() == openFile) {
	            int returnVal = fc.showOpenDialog(this);
			 System.out.println("openFile clicked");
	          if (returnVal == JFileChooser.APPROVE_OPTION) {
	                File file = fc.getSelectedFile();
	                //insert code to read in file
	               System.out.println("Opening: " + file.getName() + "." );
	            } else {
	               System.out.println("Open command cancelled by user." );
	            }
	    }
		 else
			 System.out.println("not open file");
	}
	
	public static void main(String[] args){
		LogTrackerGUI frame = new LogTrackerGUI();
	}
	
}
